﻿// <copyright file="Tag.cs" company="Microsoft Corporation">
// Copyright (c) 2008 All Right Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2009-03-06</date>
// <summary>A Tag class for the NYT Tag Search API</summary>

namespace NYTimes.Data
{
    using System.Globalization;

    /// <summary>
    /// Tag for the NY Times TagSearch API
    /// </summary>
    public class Tag
    {
        /// <summary>
        /// Gets or sets the dictionary the tag is in
        /// </summary>
        public string Dictionary { get; set; }

        /// <summary>
        /// Gets or sets the tag value
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// Gets the query for the Times Article Search API
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Not relevant for Silverlight.")]
        public string Query
        {
            get
            {
                return string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}_facet:[{1}]",
                    this.Dictionary.ToLower(CultureInfo.InvariantCulture),
                    this.Value.ToUpper(CultureInfo.InvariantCulture));
            }
        }

        /// <summary>
        /// Gets the properties and values listed
        /// </summary>
        /// <returns>a string with the property names and values</returns>
        public override string ToString()
        {
            return Synergist.Utility.GetProperties(this);
        }
    }
}
